批处理 查看"test.exe"进程是否在运行 如果有运行就结束它~

来源:百度知道 编辑:UC知道 时间:2024/05/31 03:24:49
进程是系统进程,用ntsd -c q -p pid 怎么自动查找该进程的PID码呢?

换一个命令ntsd -c q -pn test.exe

新建文本文档,将下面代码复制进去,重命名文件为a.bat,然后双击就可以了

@echo off
tasklist |find /i "test.exe"
if %errorlevel%==0 (goto kill) else (goto end)
:kill
echo test正在运行,将立即终止
taskkill /f /im test.exe
pause&exit

:end
echo test没有在运行
pause&exit

@echo off
:start
taskkill /f /t /im TEST.EXE
ping 127.1 -n 5 >nul
goto start